#include <stdio.h>
#include <math.h>
#define E 0.5*1e-5
int main()
{
	double f(double x);
	double x0, x1, x2;
	int num;
	num = 0, x0 = 0.4, x1 = 0.6;
	do {
		x2 = x1 - f(x1) * (x1 - x0) / (f(x1) - f(x0));
		num++;
		if (x2 <= 1 && x2 >= 0)
		{
			x0 = x1;
			x1 = x2;

		}
		else
			break;
	} while (fabs(x1 - x0) >= E);
	if (x2 > 1 || x2 < 0)
		printf("There is no root between 0 and 1\n");
	else
	{
		printf("The root is %lf.\n", x1);
		printf("The number of iterations is %d.\n", num);
	}

	return 0;
}
double f(double x)
{
	return x * exp(x) - 1;
}